<?

define('_ERROR_DB_CONN'           ,101);
define('_ERROR_QUERY'             ,102);
define('_ERROR_NO_DATA'           ,111);
define('_ERROR_DATA_OVERFLOW'     ,112);
define('_ERROR_AUTHED'            ,201);
define('_ERROR_NO_SELECTION'      ,301);
define('_ERROR_INVALID_PARAM'     ,401);

define("_DB_CONN_ERROR"           ,"Error: Db connection failed");

/**
* These are aids where integer
* won't help
*
*/
define('_CONN_ERROR'              , "****");

define('_1ST'                     ,  0);
define('_2ND'                     ,  1);
define('_MENU_ID'                 ,  0);
define('FIRST_ENTRY'              ,  0);
define('_FIRST_ENTRY'             ,  0);
define('ARRAY_NUMBER'             ,  1);
define('_ARRAY_NUMBER'            ,  1);
define('_IS_DEBUG'                ,  1);
define('_IS_SILENT'               ,  0);
define('_NO_COMMENT'              ," ");
define('_IS_FETCH'                ,  1);
define('_NOT_FETCH'               ,  0);

define('_DATE_DAY'                ,  0);
define('_DATE_MONTH'              ,  1);
define('_DATE_YEAR'               ,  2);

define('_NO_NUMBER'               ,"_NO_NUMBER");
define('_MANUAL_KEY_IN'           ,"_MANUAL_KEY_IN");
define('_FRESH_ENTRY'             ," ");
define('_ACTIVE'                  ,"A");
define('_BTB_ISSUED'              ,"B");
define('_CANCELED'                ,"C");
define('_NOT_ACTIVE'              ,"N");
define('_OUTSTANDING'             ,"O");
define('_PLG_RET'                 ,"P");
define('_BPB_ISSUED'              ,"U");
define('_BPG_ISSUED'              ,"G");
define('_NOT_ISSUED'              ,"Z");
define('_RETUR'                   ,"R");
define('_IS_ISSUED'               ,"I");
define('_MONTHLY_UPDATE'          ,"M");

/**
* Full listing Type of Tx can be found at
*
* @see ORACLE_DB.ECS_APPL.MST_TYPE_TX
*
*/
define('_SALDO_AWAL'              ,  0);
define('_CASH_IN'                 ,  1);
define('_BANK_IN'                 ,  2);
define('_GIRO_IN'                 ,  3);
define('_CASH_OUT'                , 11);
define('_BANK_OUT'                , 12);
define('_GIRO_OUT'                , 13);
define('_PEMBELIAN'               , 40);
define('_PBL_RETUR'               , 41);
define('_PENJUALAN'               , 50);
define('_PJL_RETUR'               , 51);
define('_MUTASI'                  , 1000);
define('_OPNAME_PLUS'             , 1100);
define('_OPNAME_MINUS'            , 1101);
define('_PRECEDING_TAG'           , "MN");
define('_TX_NOT_DEFINED'          , 9999);

define('_SELECTED'                ,"Y");
define('_NOT_SELECTED'            ," ");
define('_NOT_TOP_MANAGEMENT'      ,"N");
define('_IS_TOP_MANAGEMENT'       ,"Y");
define('IS_EXISTS'                ,0  );
define('_IS_EXISTS'               ,0  );
define('_NOT_EXISTS'              ,1  );
define('_IS_GO'                   ,0  );
define('_NOT_GO'                  ,1  );

define('_DEFAULT_SEPARATOR_01'    ,"^*^");
define('_DEFAULT_SEPARATOR_02'    ,"~^~");
define('_RET_EMPTY'               , -1);
define('_RET_NULL'                , " ");
define('_IDX_NOT_AVAILABLE'       , -1);
define('_IS_ORGANIC'              , "O");
define('_IS_NONORGANIC'           , "N");
define('_IS_MATCH'                , true);
define('_IS_NOT_MATCH'            , false);

define('_APPROVE_MODE'            ,1  );
define('_ENTRY_MODE'              ,0  );
define('_CANCEL_MODE'             ,-1 );
define('_DELETE_MODE'             ,-2 );

define('_LOG_TYPE_ENTRY'          ,"E");
define('_LOG_TYPE_MODIFY'         ,"M");
define('_LOG_TYPE_APPROVE'        ,"A");
define('_LOG_TYPE_CANCEL'         ,"C");
define('_LOG_TYPE_DELETE'         ,"D");

define('_TYPE_MP1_PRODUKSI'         ,101);
define('_TYPE_MP1_PENERIMAAN'       ,102);
define('_TYPE_MP2_PRODUKSI'         ,201);
define('_TYPE_MP2_PENERIMAAN'       ,202);
define('_TYPE_MP2_TEMPURUNG'        ,211);
define('_GET_STANDARD_INIT_FAILED'  ,"Init failed");

define('_MODE_READONLY'             ," READONLY ");
define('_MODE_DISABLED'             ," DISABLED ");
define('_IS_CHECKED'                ," CHECKED ");
define('_NO_PROPERTY'               ," ");
define('_IS_DISABLE'                ," DISABLE ");
define('_NO_MODE'                   ," ");

/**
* Rights list
*
*/
define("_ENTRY_RIGHTS"              , "ENTRY_RIGHTS");
define("_VIEW_RIGHTS"               , "VIEW_RIGHTS");
define("_MODIFY_RIGHTS"             , "EDIT_RIGHTS");
define("_EDIT_RIGHTS"               , "EDIT_RIGHTS");
define("_DELETE_RIGHTS"             , "EDIT_RIGHTS");
define("_APPROVE_RIGHTS"            , "APPROVED_RIGHTS");
define("_APPROVED_RIGHTS"           , "APPROVED_RIGHTS");
define("_CANCEL_RIGHTS"             , "DELETE_RIGHTS");
define("_FINALIZE_RIGHTS"           , "FINALIZE_RIGHTS");
define("_JOURNAL_RIGHTS"            , "JOURNAL_RIGHTS");
define("_PROGRAM_RIGHTS"            , "PROGRAMS");

/**
 * @see NECS_APPL.MST_MODEL_TYPE
 */
define("_MODEL_TYPE_PRODUKSI",        1);
define("_MODEL_TYPE_RAKITAN",         2);
define("_MODEL_TYPE_NORMAL",          3);
define("_MODEL_TYPE_ALL",             0);

/**
 * type of includeThis
 */
define("_TYPE_CSS"                  , "CSS");
define("_TYPE_JS"                   , "JS");

/**
 * based on tocmenu
 *
 */
define("_SOURCE_PAYMENT"            , "31");

/**
 * @see C_B_HDR.IN_OUT
 */
define("_CASH_BANK_IN",               "IN");
define("_CASH_BANK_OUT",              "OUT");
define("_CASH_BANK_RGL_CODE",         "RGL");
define("_CASH_BANK_RGL_NAME",         "Reguler");
define("_CASH_BANK_INVOICE_CODE",     "IVC");
define("_CASH_BANK_INVOICE_NAME",     "Invoice");
define("_CASH_BANK_CCL_DP_CODE",      "DPC");
define("_CASH_BANK_CCL_DP_NAME",      "DP Cancel");
define("_CASH_BANK_DP_CODE",          "DP");
define("_CASH_BANK_DP_NAME",          "DP");
define("_CASH_BANK_TX_CASH",          "CASH");
define("_CASH_BANK_TX_BANK",          "BANK");
define("_CASH_BANK_TX_GIRO",          "GIRO");
define("_CURRENCY_HANDLE_MUL",        "*");
define("_CURRENCY_HANDLE_DIV",        "/");

function GoBack($time,$toUrl){

	echo "<html>
				<head>
				<meta http-equiv='refresh' content='$time; URL=$toUrl'>
				</head>
				<body></body>
				</html>";
}

/**
* Auto redirect to the specified url
*
* @param integer    $time   in seconds
* @param string     $toUrl
*
*/
function jumpTo($time, $toUrl){

  echo "<html>
				<head>
				<meta http-equiv='refresh' content='$time; URL=$toUrl'>
				</head>
				<body></body>
				</html>";
}

function OUT(){

	$_SESSION["LETME_OUT"] = "OUT";
}

/**
* Add with specfied zero leading
*
* @param  string    $srcStr     source string
*/
function addDigit($srcStr){

	$fullLength = 6 ; //we use 7 digits
	$ftcStr			= strlen($srcStr);

	/**
	* now we have fetched string length and
	* it subtracted the full length and the remainders are the digits to be added
	*
	*/
	$addLoop		= $fullLength - $ftcStr;
	$addStr			= "";

	for($i = 0; $i < $addLoop; $i++){
		$addStr .= "0";
	}

	return $addStr;
}

/**
* Add with specfied zero leading
*
* @param  integer   $length     source length
* @param  string    $srcStr     source string
*
*/
function addDigit2($length,$srcStr){

	$fullLength = $length ;
	$ftcStr			= strlen($srcStr);

	/**
	* now we have fetched string length and
	* it subtracted the full length and the remainders are the digits to be added
	*
	*/
	$addLoop		= $fullLength - $ftcStr;
	$addStr			= "";

	for($i = 0; $i < $addLoop; $i++){
		$addStr .= "0";
	}

	return $addStr;
}

/**
* Process die()
* With user defined error msg
*
* @param string $errMsg
*
*/
function usrDie($errMsg){

  $dbgTrace = debug_backtrace();
  $addMsg	  = "<br/><h1 style='color:red; font-size:24px'>(".$dbgTrace[0]["file"].":".$dbgTrace[0]["line"].")";

  $errMsg   = $addMsg . $errMsg;
  die(" ".$errMsg."<br/></font>");
}

/**
* Print the error msg with template of course :D
*
* @param  string  $errMsg     error message
*
*/
function usrError($errMsg){

	$dbgTrace = debug_backtrace();
  $addMsg	  = "<br/><h1 style='color:red; font-size:24px'>(".$dbgTrace[0]["file"].":".$dbgTrace[0]["line"].")";

  $errMsg   = $addMsg . $errMsg;
	echo "<br/><font size='16'> ".$errMsg." </font>\n";
}

/**
* Print the error msg with template of course :D
*
* @param  string  $usrMsg     user message
*
*/
function usrMsg($usrMsg){

	echo "<br/><font size='10'> ".$usrMsg." </font>\n";
}

/**
* Print the error msg with template of course :D
* in javascript
*
* @param  string  $usrMsg     user message
*
*/
function usrMsgJs($usrMsg){

  $jsScript = " alert(\"".$usrMsg."\"); ";

	echo CGJavascript::jsScript(NULL,
	                            $jsScript);
}

/**
* Print the error msg with javascript alert
* and die()!!!
*
* @param  string  $usrMsg     user message
*
*/
function usrDieJs($errMsg){

  $dbgTrace = debug_backtrace();
  $addMsg	  = $dbgTrace[0]["file"].":".$dbgTrace[0]["line"];

  $errMsg   = $addMsg ." ". $errMsg;

  $jsScript = " alert(\"".$errMsg."\"); ";

	echo CGJavascript::jsScript(NULL,
	                            $jsScript);

  die();
}

/**
* Simple debug info
*
*/
function dbgInfo($strMsg, $valToInspect, $isDbg = _IS_DEBUG){

  if($isDbg == _IS_DEBUG){

    $dbgTrace = debug_backtrace();
    echo	"<br/>(".$dbgTrace[0]["file"].":".$dbgTrace[0]["line"].") ".
          $strMsg. " : ".
          $valToInspect." <br/>\n";
  }
}

/**
*----------------------------------------------------------------------------------------
* Generally used functions
*
*/

/**
* Fetch login
* Check if the user, pass and company is exist and active
* return true  if the user is active and exists
*        false if null return from the db fetch
*
* @param  string    $COracle
* @param  string    $user
* @param  string    $pass
* @param  string    $company
* @param  string    $srcDb
* @return booelan   true on success and false on failed
*
*/
function fetchRelogin( &$COracle,
    			             &$user,
    			             &$pass,
    			             &$company,
    			             &$srcDb,
    			             &$nrows,
    			             &$reauthId){

  $query  = "SELECT USERID ".
            "FROM ".$srcDb." ".
            "WHERE  USERID='".$user."' ".
                    "AND PASSWORD='".$pass."' ".
                    "AND COMPANY='".$company."' ".
                    "AND STATUS=1 ";

  $COracle->execFetchQuery($query,
                           $nrows,
                           $result);

  $reauthId = $user;
}

/**
*
* @param    string    $COracle
* @param    string    $priv
* @param    string    $user
* @param    string    $desc
* @param    string    $srcDb
* @return   string
*
*/
function chk_priv(&$COracle,
                  $priv,
                  $userId,
                  $desc,
                  &$srcDb){

	$query = "SELECT ".$priv." ".
	         "FROM ".$srcDb." ".
	         "WHERE USERID='".$userId."' ".
	                "AND description='".$desc."' ";

  $COracle->execFetchQuery($query,
                           $nrows,
                           $result);

	if($nrows >= 0){
		//echo "Entry priv: " .$resultschkpriv["$p"][1];
		//authed ok
		if($result[$priv][0] == 1){

			return "OK";
		}else{

			return "NO_PRIV";
		}
	}else{

		return "NOT_EXIST";
	}
}

/**
* filter out any NULL entry of an array
*
* @param  array   $srcArray
*
*/
function filterOutNull(&$srcArray){

  define("_MOVE_CURSOR_BY_1"  , 1);

  /**
  * Get max size
  * Use Loop to find any NULL entry
  * if exist fetch index and splice
  *
  * Re-Get and re-Loop
  *
  */
  $nNull    = 0;
  $isNull   = false;
  $szArray  = sizeof($srcArray);

  if($szArray > 0){

    /**
    * Fetch how many NULL Entry
    *
    */
    for($iDtl = 0; $iDtl < $szArray; $iDtl++){

      if($srcArray[$iDtl] == NULL){

        $nNull++;
      }
    }

    /**
    * For each nNull
    * we slice and splice the array
    * and reCalc the szArray
    *
    */
    for($iNull = 0; $iNull < $nNull; $iNull++){

      $szArray = sizeof($srcArray);

      for($iDtl = 0; $iDtl < $szArray; $iDtl++){

        if($srcArray[$iDtl] == NULL){

          $orgCursor  = $iDtl;
          $dropPoint  = $iDtl + _MOVE_CURSOR_BY_1;
          $bufTail    = array_slice($srcArray, $dropPoint);

          /**
          * Decrease sizeof srcArray (dummy)
          * by 1
          *
          */
          $recycleBin = array_pop($srcArray);

          array_splice($srcArray,
                       $orgCursor,        // original cursor which point to splice start element
                       sizeof($bufTail),
                       $bufTail);

          break;
        }
      }
    }
  }else{

    /**
    * Do Nothing
    *
    */
  }
}

/**
* process the menu ID
*
* @param  string  $srcStrCaller   it is from $_SESSION["source_caller"]
*
* @return string  the menu id
*
*/
function procMenuTag(&$srcStrCaller){

  /**
  * extract menu id from $srcStrCaller
  *
  * Clear out unserscore "_"
  *
  */
  $tmpString = explode("_",
                       &$srcStrCaller);

  /**
  * Clear out dot "." of the _2ND string
  *
  */
  $tmpString = explode(".",
                       $tmpString[_2ND]);


  $menuId = $tmpString[_MENU_ID];

  $mnTag  = _PRECEDING_TAG . $menuId;

  return $mnTag;
}

/**
* process the menu ID
*
* @param  string  $COracle
* @param  string  $srcModul
* @param  string  $srcDb
* @param  string  $mnTag
*
* @return string  the menu id
*
*/
function procMenuTag2(&$COracle,
                      &$srcModul,
                      &$srcDb,
                      &$mnTag){

  CGFetchers::fetchLevelMn($COracle,
                           $srcModul,
                           $srcDb,
                           $menuId);

  $mnTag = _PRECEDING_TAG . $menuId;

  return $mnTag;
}

/**
* Manually reextract periode
*
* @param  date  $srcDate
*
* @return date
*
*/
function procInternalPeriode($srcDate){

  $thisPeriode = explode("-",$srcDate);
	$thisPeriode = $thisPeriode[_DATE_MONTH].
	               "-".
	               $thisPeriode[_DATE_YEAR];

  return $thisPeriode;
}

/**
* Std style with customised size
*
* @param  integer $size
*
* @return string
*
*/
function stdStyle($size){

  return " size='".$size."' ";
}

/**
* Std style with 100% width and height
*
* @param  void
*
* @return string
*
*/
function stdStyle100(){

  return " style='height:100%; width:100%' ";
}

/**
* Std numeric style with customised size
*
* @param  integer $size
*
* @return string
*
*/
function stdNumStyle($size){

  return " style='text-align:right' size='".$size."' ";
}

/**
* Std Numeric style with 100% width and height
*
* @param  void
*
* @return string
*
*/
function stdNumStyle100(){

  return " style='height:200%;
                  width:100%;
                  text-align:right'";
}

/**
* @package Misc
*
*/
class Misc{

  /**
   * helper to return empty array
   * if the variable is null
   *
   * @param mixed $var
   */
  function retArray($var){

    /**
     * check if is array
     * if isArray > 0 then it's array
     */
    $isArray = sizeof($var);

    if(is_array($var)){

      return $var;
    }else{

      /**
       * check if it is not null
       */
      if($var){

        return array($var);
      }else{

        return array("");
      }
    }
  }

  function GoBack($time,$toUrl){

  	echo "<html>
  				<head>
  				<meta http-equiv='refresh' content='$time; URL=$toUrl'>
  				</head>
  				<body></body>
  				</html>";
  }

  /**
  * Auto redirect to the specified url
  *
  * @param integer    $time   in seconds
  * @param string     $toUrl
  *
  */
  function jumpTo($time, $toUrl){

    echo "<html>
  				<head>
  				<meta http-equiv='refresh' content='$time; URL=$toUrl'>
  				</head>
  				<body></body>
  				</html>";
  }

  function OUT(){

  	$_SESSION["LETME_OUT"] = "OUT";
  }

  /**
  * Add with specfied zero leading
  *
  * @param  string    $srcStr     source string
  */
  function addDigit($srcStr){

  	$fullLength = 6 ; //we use 7 digits
  	$ftcStr			= strlen($srcStr);

  	/**
  	* now we have fetched string length and
  	* it subtracted the full length and the remainders are the digits to be added
  	*
  	*/
  	$addLoop		= $fullLength - $ftcStr;
  	$addStr			= "";

  	for($i = 0; $i < $addLoop; $i++){
  		$addStr .= "0";
  	}

  	return $addStr;
  }

  /**
  * Add with specfied zero leading
  *
  * @param  integer   $length     source length
  * @param  string    $srcStr     source string
  *
  */
  function addDigit2($length,$srcStr){

  	$fullLength = $length ;
  	$ftcStr			= strlen($srcStr);

  	/**
  	* now we have fetched string length and
  	* it subtracted the full length and the remainders are the digits to be added
  	*
  	*/
  	$addLoop		= $fullLength - $ftcStr;
  	$addStr			= "";

  	for($i = 0; $i < $addLoop; $i++){
  		$addStr .= "0";
  	}

  	return $addStr;
  }

  /**
  * Process die()
  * With user defined error msg
  *
  * @param string $errMsg
  *
  */
  function usrDie($errMsg){

    $dbgTrace = debug_backtrace();
    $addMsg	  = "<br/><h1 style='color:red; font-size:24px'>(".$dbgTrace[0]["file"].":".$dbgTrace[0]["line"].")";

    $errMsg   = $addMsg . $errMsg;
    die(" ".$errMsg."<br/></font>");
  }

  /**
  * Print the error msg with template of course :D
  *
  * @param  string  $errMsg     error message
  *
  */
  function usrError($errMsg){

  	$dbgTrace = debug_backtrace();
    $addMsg	  = "<br/><h1 style='color:red; font-size:24px'>(".$dbgTrace[0]["file"].":".$dbgTrace[0]["line"].")";

    $errMsg   = $addMsg . $errMsg;
  	echo "<br/><font size='16'> ".$errMsg." </font>\n";
  }

  /**
  * Print the error msg with template of course :D
  *
  * @param  string  $usrMsg     user message
  *
  */
  function usrMsg($usrMsg){

  	echo "<br/><font size='10'> ".$usrMsg." </font>\n";
  }

  /**
  * Print the error msg with template of course :D
  * in javascript
  *
  * @param  string  $usrMsg     user message
  *
  */
  function usrMsgJs($usrMsg){

    $jsScript = " alert(\"".$usrMsg."\"); ";

  	echo CGJavascript::jsScript(NULL,
  	                            $jsScript);
  }

  /**
  * Print the error msg with javascript alert
  * and die()!!!
  *
  * @param  string  $usrMsg     user message
  *
  */
  function usrDieJs($errMsg){

    $dbgTrace = debug_backtrace();
    $addMsg	  = $dbgTrace[0]["file"].":".$dbgTrace[0]["line"];

    $errMsg   = $addMsg ." ". $errMsg;

    $jsScript = " alert(\"".$errMsg."\"); ";

  	echo CGJavascript::jsScript(NULL,
  	                            $jsScript);

    die();
  }

  /**
  * Simple debug info
  *
  */
  function dbgInfo($strMsg, $valToInspect, $isDbg = _IS_DEBUG){

    if($isDbg == _IS_DEBUG){

      $dbgTrace = debug_backtrace();
      echo	"<br/>(".$dbgTrace[0]["file"].":".$dbgTrace[0]["line"].") ".
            $strMsg. " : ".
            $valToInspect." <br/>\n";
    }
  }

  /**
  *----------------------------------------------------------------------------------------
  * Generally used functions
  *
  */

  /**
  * Fetch login
  * Check if the user, pass and company is exist and active
  * return true  if the user is active and exists
  *        false if null return from the db fetch
  *
  * @param  string    $COracle
  * @param  string    $user
  * @param  string    $pass
  * @param  string    $company
  * @param  string    $srcDb
  * @return booelan   true on success and false on failed
  *
  */
  function fetchRelogin( &$COracle,
      			             &$user,
      			             &$pass,
      			             &$company,
      			             &$srcDb,
      			             &$nrows,
      			             &$reauthId){

    $query  = "SELECT USERID ".
              "FROM ".$srcDb." ".
              "WHERE  USERID='".$user."' ".
                      "AND PASSWORD='".$pass."' ".
                      "AND COMPANY='".$company."' ".
                      "AND STATUS=1 ";

    $COracle->execFetchQuery($query,
                             $nrows,
                             $result);

    $reauthId = $user;
  }

  /**
  *
  * @param    string    $COracle
  * @param    string    $priv
  * @param    string    $user
  * @param    string    $desc
  * @param    string    $srcDb
  * @return   string
  *
  */
  function chk_priv(&$COracle,
                    $priv,
                    $userId,
                    $desc,
                    &$srcDb){

  	$query = "SELECT ".$priv." ".
  	         "FROM ".$srcDb." ".
  	         "WHERE USERID='".$userId."' ".
  	                "AND description='".$desc."' ";

    $COracle->execFetchQuery($query,
                             $nrows,
                             $result);

  	if($nrows >= 0){
  		//echo "Entry priv: " .$resultschkpriv["$p"][1];
  		//authed ok
  		if($result[$priv][0] == 1){

  			return "OK";
  		}else{

  			return "NO_PRIV";
  		}
  	}else{

  		return "NOT_EXIST";
  	}
  }

  /**
  * filter out any NULL entry of an array
  *
  * @param  array   $srcArray
  *
  */
  function filterOutNull(&$srcArray){

    define("_MOVE_CURSOR_BY_1"  , 1);

    /**
    * Get max size
    * Use Loop to find any NULL entry
    * if exist fetch index and splice
    *
    * Re-Get and re-Loop
    *
    */
    $nNull    = 0;
    $isNull   = false;
    $szArray  = sizeof($srcArray);

    if($szArray > 0){

      /**
      * Fetch how many NULL Entry
      *
      */
      for($iDtl = 0; $iDtl < $szArray; $iDtl++){

        if($srcArray[$iDtl] == NULL){

          $nNull++;
        }
      }

      /**
      * For each nNull
      * we slice and splice the array
      * and reCalc the szArray
      *
      */
      for($iNull = 0; $iNull < $nNull; $iNull++){

        $szArray = sizeof($srcArray);

        for($iDtl = 0; $iDtl < $szArray; $iDtl++){

          if($srcArray[$iDtl] == NULL){

            $orgCursor  = $iDtl;
            $dropPoint  = $iDtl + _MOVE_CURSOR_BY_1;
            $bufTail    = array_slice($srcArray, $dropPoint);

            /**
            * Decrease sizeof srcArray (dummy)
            * by 1
            *
            */
            $recycleBin = array_pop($srcArray);

            array_splice($srcArray,
                         $orgCursor,        // original cursor which point to splice start element
                         sizeof($bufTail),
                         $bufTail);

            break;
          }
        }
      }
    }else{

      /**
      * Do Nothing
      *
      */
    }
  }

  /**
  * process the menu ID
  *
  * @param  string  $srcStrCaller   it is from $_SESSION["source_caller"]
  *
  * @return string  the menu id
  *
  */
  function procMenuTag(&$srcStrCaller){

    /**
    * extract menu id from $srcStrCaller
    *
    * Clear out unserscore "_"
    *
    */
    $tmpString = explode("_",
                         &$srcStrCaller);

    /**
    * Clear out dot "." of the _2ND string
    *
    */
    $tmpString = explode(".",
                         $tmpString[_2ND]);


    $menuId = $tmpString[_MENU_ID];

    $mnTag  = _PRECEDING_TAG . $menuId;

    return $mnTag;
  }

  /**
  * process the menu ID
  *
  * @param  string  $COracle
  * @param  string  $srcModul
  * @param  string  $srcDb
  * @param  string  $mnTag
  *
  * @return string  the menu id
  *
  */
  function procMenuTag2(&$COracle,
                        &$srcModul,
                        &$srcDb,
                        &$mnTag){

    CGFetchers::fetchLevelMn($COracle,
                             $srcModul,
                             $srcDb,
                             $menuId);

    $mnTag = _PRECEDING_TAG . $menuId;

    return $mnTag;
  }

  /**
  * Manually reextract periode
  *
  * @param  date  $srcDate
  *
  * @return date
  *
  */
  function procInternalPeriode($srcDate){

    $thisPeriode = explode("-",$srcDate);
  	$thisPeriode = $thisPeriode[_DATE_MONTH].
  	               "-".
  	               $thisPeriode[_DATE_YEAR];

    return $thisPeriode;
  }

  /**
  * Std style with customised size
  *
  * @param  integer $size
  *
  * @return string
  *
  */
  function stdStyle($size){

    return " size='".$size."' ";
  }

  /**
  * Std style with 100% width and height
  *
  * @param  void
  *
  * @return string
  *
  */
  function stdStyle100(){

    return " style='height:100%; width:100%' ";
  }

  /**
  * Std numeric style with customised size
  *
  * @param  integer $size
  *
  * @return string
  *
  */
  function stdNumStyle($size){

    return " style='text-align:right' size='".$size."' ";
  }

  /**
  * Std Numeric style with 100% width and height
  *
  * @param  void
  *
  * @return string
  *
  */
  function stdNumStyle100(){

    return " style='height:200%;
                    width:100%;
                    text-align:right'";
  }

  function stdProperties(){

    return " onFocus='setYellow2(this);' ".
           " onBlur ='setWhite2(this);'  ";
  }

  /**
   * it handles enter key
   *
   */
  function stdKeyProp($element){

    return " onkeydown='GMisc.enterKey(event,
                                       \"".$element."\");' ";
  }

  /**
   * it handles numbers field
   * and stricts out NULL to "0"
   *
   * @return string
   */
  function stdNoNull(){

    return " onFocus='GMisc.setYellow2(this);' ".
           " onBlur ='GMisc.setWhite2(this);
                      GMisc.noNull(this);'  ";
  }

  /**
  * Set to true if source val is NULL
  *
  * @param  string  $srcValue
  * @param  numeber $toValue
  *
  */
  function setValue(&$srcValue, $toValue){

    $srcValue = $toValue;
  }

  /**
  * Find out what mode are we in
  * edit, delete, approve or cancel
  *
  * @param  array $srcPost
  * @return string
  *
  */
  function thisMode(&$srcPost){

    if($srcPost["modify"]){

      return _MODIFY_RIGHTS;
    }else
    if($srcPost["delete"]){

      return _DELETE_RIGHTS;
    }else
    if($srcPost["approve"]){

      return _APPROVE_RIGHTS;
    }else
    if($srcPost["cancel"]){

      return _CANCEL_RIGHTS;
    }else{

      /* Do nothing */
    }
  }

  /**
  * Find out what button are we goin to use
  * edit, delete, approve or cancel
  *
  * @param  array $srcPost
  * @param  array $srcPost
  * @param  array $srcPost
  * @return string
  *
  */
  function thisButton(&$srcPost,
		                  &$btnName,
		                  &$btnValue){

		if($srcPost["modify"]){

      $btnName  = "modify";
      $btnValue = "Modify";
    }else
    if($srcPost["delete"]){

      $btnName  = "delete";
      $btnValue = "Delete";
    }else
    if($srcPost["approve"]){

      $btnName  = "approve";
      $btnValue = "Approve";
    }else
    if($srcPost["cancel"]){

      $btnName  = "cancel";
      $btnValue = "Cancel";
    }else{

      /* Do nothing */
    }
  }
}
?>